package T2;

public class Circle {
    private int radius;//半径
    private Point center;//圆心

    public Circle(){
        this(new Point(),0);
    }
    public Circle(int x,int y, int r){
        this(new Point(x,y),r);
    }
    public Circle(Point c, int r) {
        if (c == null || r < 0){
            throw new InvalidException("参数无意义!");
        }
        center=c;
        radius=r;
    }

    public int getRadius() {
        return radius;
    }

    public Point getCenter() {
        return center;
    }

    public double perimeter(){
//        计算周长
        return 2*Math.PI*radius;
    }
    public double area(){
//        计算面积
        return Math.PI*Math.pow(radius,2);
    }
    public int relation(Circle c) {
        double d = center.distance(c.center);
        if (d == 0 && radius == c.radius) {
            return 0; // 同一圆
        } else if (d == 0) {
            return 1; // 同心圆
        } else if (d < Math.abs(radius - c.radius)) {
            return 4; // 包含
        } else if (d < radius + c.radius) {
            return 2; // 相交
        } else {
            return 3; // 分离
        }
    }
}
